using MilkShake;
using UnityEngine;

public class BurningArea : MonoBehaviour
{
	public ParticleSystem ps;

	public Collider2D fireCollider;

	public ShakePreset shake;

	public BodyPartFire fire;

	public float damage;

	public float fireChance = 0.5f;

	public float duration = 1f;

	public float burstForce;

	private void Start()
	{
		Object.Destroy(base.gameObject, duration + 3f);
		Invoke("StopFire", duration);
		Invoke("StopBurstForce", 0.1f);
		Shaker.ShakeAll(shake);
	}

	private void StopFire()
	{
		fireCollider.enabled = false;
		ps.Stop();
	}

	private void StopBurstForce()
	{
		burstForce = 0f;
	}

	private void OnTriggerEnter2D(Collider2D collision)
	{
		if (collision.gameObject.TryGetComponent<BodyPart>(out var component) && (bool)component.body && !component.isFireproof && !(Mathf.Abs(base.transform.position.y - component.body.transform.position.y) > fireCollider.bounds.size.y))
		{
			component.OnHit(null, Vector2.right, Vector2.zero);
			if (component.onFire == null && component.damageRatio >= 1f && fireChance > Random.value)
			{
				component.onFire = Object.Instantiate(fire, component.transform);
				component.onFire.damage = damage;
			}
			if (burstForce > 0f && component.body.zombie.isWeaponKnockbackable)
			{
				component.body.zombie.Knockback(burstForce, "knockback");
			}
		}
	}
}
